<extend name="Public/base"/>

<block name="body">
		<style>
			.status1 {background-color: #2d7200;}
			.status0 {background-color: #ff2610;}
		</style>
    <div class="main-title">
        <h2>菜单模型 列表</h2>
		
    </div>
<strong><font color="red">怎么设置菜单？【远程清除菜单】->点击需要设置的菜单的【状态】变为绿色</font></strong>
    <div class="cf">
        <a class="btn" href="{:U('click_add')}">添加菜单模型</a>
		<button class="btn ajax-post confirm" url="{:U('delmenu')}" target-form="ids">远程清除菜单</button>
        <!-- 高级搜索 -->
        <div class="search-form fr cf">
            <div class="sleft">
                <input type="text" name="title" class="search-input" value="{:I('title')}" placeholder="输入关键词含有内容">
                <a class="sch-btn" href="javascript:;" id="search" url="__SELF__"><i class="btn-search"></i></a>
            </div>
        </div>
    </div>

    <div class="data-table table-striped">
        <form class="ids">
            <table>
                <thead>
                    <tr>
                        <th class="row-selected">
                            <input class="checkbox check-all" type="checkbox">
                        </th>
                        <th width=20>ID</th>
                        <th width=200>菜单名称</th>
                        
                        <th width=100>循环周期</th>
						<th width=100>启用日期</th>
						<th width=40>状态</th>
						<th width=70>操作</th>
                    </tr>
                </thead>
                <tbody>
				<notempty name="list">
                <volist name="list" id="menu">
                    <tr>
                        <td><input class="ids row-selected" type="checkbox" name="id[]" value="{$menu.id}"></td>
                        <td>{$menu.id}</td>
                        <td>{$menu.title}</td>
                        <td>{$menu.circletime}</td>
					    <td>{$menu.update_time|date="Y/m/d",###}</td>
                        <td><a class="ajax-get" href="{:U('Keywordview/setclickmenu',array('id'=>$menu['id']))}"><span class="status{$menu.status}">状态</span></a></td>
                        <td><a class="confirm" title="编辑" href="{:U('edit_clickmenu?id='.$menu['id'])}">编辑</a>
                            <a class="confirm ajax-get" title="删除" href="{:U('del_clickmemu?id='.$menu['id'])}">删除</a>
							<a class="copy-button" href="#" value="{$menu.id}"type="button" title='{$menu.postmenu}'>预览JSON</a>
                        </td>
                    </tr>
                </volist>
				<else/>
				<td colspan="12" class="text-center"> aOh! 暂时还没有菜单模型! </td>
				</notempty>
                </tbody>
            </table>
        </form>
        <!-- 分页 -->
        <div class="page">

        </div>
    </div>
</block>

<block name="script">
    <script type="text/javascript">
        $(function() {
            //搜索功能
            $("#search").click(function() {
                var url = $(this).attr('url');
                var query = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });
            //回车搜索
            $(".search-input").keyup(function(e) {
                if (e.keyCode === 13) {
                    $("#search").click();
                    return false;
                }
            });
            //导航高亮
            highlight_subnav('{:U('index')}');
            //点击排序
        	$('.list_sort').click(function(){
        		var url = $(this).attr('url');
        		var ids = $('.ids:checked');
        		var param = '';
        		if(ids.length > 0){
        			var str = new Array();
        			ids.each(function(){
        				str.push($(this).val());
        			});
        			param = str.join(',');
        		}

        		if(url != undefined && url != ''){
        			window.location.href = url + '/ids/' + param;
        		}
        	});
        });
//排序方法
function sort(id,num){
    $.get('{:U("Keywordview/sort")}', { id: id,num:num }, function(jsondata){
		var return_data  = eval(jsondata);
		$("#7_"+id).attr('value', return_data);
		location.reload();
	}); 
}
    </script>
</block>